package com.iam.core.entities;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.iam.core.config.RequestEnumJsonDeserialize;
import com.iam.core.enumhandler.MyIntegerToEnumHandler;
import com.iam.core.enums.EntityStatus;
import lombok.Data;

import java.util.Date;

/**
 * @author baily
 */
@Data
public class BasePaginationEntity extends BaseEntity {

    @TableField(exist = false)
    public Integer pageNum;

    @TableField(exist = false)
    public Integer pageSize;

    public BasePaginationEntity(Integer pageNum, Integer pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public BasePaginationEntity() {
        this.pageNum = 1;
        this.pageSize = 10;
    }

    /**
     * 创建者
     */
    public Integer creator;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("create_at")
    public Date createAt;
    /**
     * 更新者
     */
    public Integer updator;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("update_at")
    public Date updateAt;

    /**
     * 状态(0：已删除，1：正常)
     */
    @TableLogic
    @TableField(value = "status", typeHandler = MyIntegerToEnumHandler.class)
    @JsonDeserialize(using = RequestEnumJsonDeserialize.class)
    public EntityStatus status;

}
